﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 寻路小帮手  找到路径 找到敌人
/// </summary>
public class Pathfinding
{
    //先找到路径
    //判断下一步路径属性
    //打破核心后再刷新路径
    Vector3 startVec;//开始位置
    Vector3 TargetVec;//目标位置
    Vector3 atPresentVec;//当前位置
    int[] endPos;
    List<int[]> pathList = new List<int[]>();

    PathMap pathMap;
    public Pathfinding()
    {
        PathMap = new PathMap();
        endPos = new int[2];
    }

    public List<int[]> PathList { get => pathList; set => pathList = value; }
    public PathMap PathMap { get => pathMap; set => pathMap = value; }
    public int[] EndPos { get => endPos; set => endPos = value; }

    /// <summary>
    /// 更新路径
    /// </summary>
    public void UpdatePath(int[] pathStart, int[] pathEnd)
    {
        EndPos[0] = pathEnd[0];
        EndPos[1] = pathEnd[1];
        pathList.Clear();
        foreach (var item in PathMap.SetStartAndEndPath(pathStart, pathEnd))
        {
            pathList.Add(item);
        }
    }

}
